package com.youdoneed.news.news.service;

import com.youdoneed.news.common.util.StringUUIdUtil;
import com.youdoneed.news.news.dao.CmfPostsReadlogMapper;
import com.youdoneed.news.news.entity.CmfPostsReadlog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class CmfPostReadLogService {
	
	private final Logger LOGGER = LoggerFactory.getLogger(CmfPostReadLogService.class);
	
	@Autowired
	CmfPostsReadlogMapper cmfPostsReadlogMapper;
	/**
	 * 保存用户浏览记录
	 * @param userId
	 * @param postId
	 * @return
	 * @author hexz
	 * @date 2017.6.26
	 */
	@Transactional
	public boolean savePostReadLog(String userId,Long postId) {
		//获取用户信息
		CmfPostsReadlog cmfPostsReadlog = new CmfPostsReadlog();
		cmfPostsReadlog.setCreateTime(new Date());
		cmfPostsReadlog.setPostsId(postId);
		cmfPostsReadlog.setUserId(userId);
		cmfPostsReadlog.setPostsReadlogId(StringUUIdUtil.getUUID());
		cmfPostsReadlogMapper.insert(cmfPostsReadlog);
		return true;
	}

}
